package com.yxinsur.imc.web.controller.business;

import java.util.List;

import com.yxinsur.imc.business.form.RateFactorForm;
import com.yxinsur.imc.business.service.IImcRateFactorValueService;
import com.yxinsur.imc.business.vo.InsFactorVo;
import com.yxinsur.imc.business.vo.RateFactorKeyVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yxinsur.imc.common.core.controller.BaseController;
import com.yxinsur.imc.common.core.domain.AjaxResult;
import com.yxinsur.imc.business.service.IImcRateFactorKeyService;
import com.yxinsur.imc.common.utils.poi.ExcelUtil;
import com.yxinsur.imc.common.core.page.TableDataInfo;

/**
 * 产品费率因子KEYController
 * 
 * @author imc
 * @date 2021-03-30
 */
@Api(value="险种费率因子接口服务",tags={"3.[需求变动已弃用]险种费率因子KEY/VALUE接口服务"})
@RestController
@RequestMapping("/business/rate/factor")
public class ImcRateFactorController extends BaseController
{
    @Autowired
    private IImcRateFactorKeyService imcRateFactorKeyService;
    @Autowired
    private IImcRateFactorValueService imcRateFactorValueService;

    /**
     * 新增产品费率因子
     */
    @ApiOperation("费率因子新增")
    @PostMapping("/{repoInsId}")
    public AjaxResult add(@PathVariable Long repoInsId,@RequestBody List<RateFactorForm> rateFactorKeyForm)
    {
        return toAjax(imcRateFactorKeyService.insertImcRateFactor(repoInsId,rateFactorKeyForm));
    }

    /**
     * 获取产品所有因子列表
     */
    @ApiOperation("获取产品所有因子列表")
    @PostMapping("/ins/{repoInsId}")
    public AjaxResult getFactors(@PathVariable Long repoInsId)
    {
        List<InsFactorVo> factorVos = this.imcRateFactorKeyService.getInsFactorListByRepoInsId(repoInsId);
        return AjaxResult.success(factorVos);
    }
    /**
     * 费率因子删除
     */
    @ApiOperation("费率因子删除")
	@DeleteMapping("/{repoInsIds}")
    public AjaxResult remove(@PathVariable Long[] repoInsIds)
    {
        return toAjax(imcRateFactorKeyService.deleteImcRateFactorKeyByRepoInsIds(repoInsIds));
    }

}
